package learn.advance.tcp;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.ServerSocket;
import java.net.Socket;

class  Demo1TCPClient{
    public static void Test() throws IOException {
        ServerSocket server_socket=new ServerSocket(30000);
        Socket socket=server_socket.accept();
        InputStream is=socket.getInputStream();

        byte[] bytes=new byte[1024];
        int len=is.read(bytes);

        System.out.println(new String(bytes,0,len));

        OutputStream os=socket.getOutputStream();
        os.write("收到".getBytes());

        socket.close();
        server_socket.close();
    }
}



public class TestTcp {
    public static void main(String[] args) throws IOException {
        Demo1TCPClient.Test();
    }
}
